//package com.zgyd.controller;
//
//import com.zgyd.service.IChatHistoryService;
//import lombok.RequiredArgsConstructor;
//import org.springframework.ai.chat.client.ChatClient;
//import org.springframework.ai.chat.memory.ChatMemory;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//import reactor.core.publisher.Flux;
//
//@RequiredArgsConstructor
//@RestController
//@RequestMapping("/ai")
//public class CustomerServiceController {
//
//    private final ChatClient serviceChatClient;//注意bean的名字已经换成了serviceChatClient
//    private final IChatHistoryService chatHistoryService;
//
//    @RequestMapping(value = "/service", produces = "text/html;charset=utf-8")
//    public Flux<String> service(String prompt, String chatId) {
//        chatHistoryService.saveChatHistory("service",chatId);
//
//        // 2.请求模型
//        return serviceChatClient.prompt()
//                .user(prompt)
//                .advisors(a -> a.param(ChatMemory.CONVERSATION_ID, chatId))
//                .stream()
//                .content();
//    }
//}